<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>考试管理系统</title>
  <link rel="stylesheet" href="css/login.css">
  <script src="js/global.js"></script>
</head>
<body class="login-bg">
    <canvas id="fullstarbg">你的浏览器不支持canvas标签</canvas>
    <div class="login">
        <div class="message">考试系统登录</div>
        <div id="darkbannerwrap"></div>   
        <form method="post" id="fmLogin" class="layui-form" onsubmit="return false;">
            <input id="loginname" name="loginName" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>
    <script>
            layui.use(['form'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
				//				$("#loginToken").val(globalData.myToken);
                //监听提交
                form.on('submit(login)',
					function(data) {
						//登录提交
						
						$.ajax({
						        type : "post",
						        url : globalData.permissionServer+"/login",
							    data:$("#fmLogin").serialize(),//需要传递到服务端的数据
							    dataType:'json',//服务端响应数据类型
						        xhrFields: {
						            withCredentials: true
						        },
						        success : function(res) {
									
						            if(res.code == 0 ){
										var obj=JSON.parse(res.data);
						            	//保存相关数据到本地缓存
						            	globalData.setUserInfo(obj.userId,obj.userName);
										
						            	//转向首页
						            	window.location.href="index.html";
						            }else{
						            	layer.msg(res.msg,{
						            		icon:2,
						            		time:2000
						            	});
						            }
						        }
						    });
						return false;
					}
				);
            });

        </script>

    
    <!-- 底部结束 -->
    
</body>
</html>